﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.ComponentModel;


namespace Negocio
{
   public class Evaluation: PersistentObject,IDataErrorInfo
    {
        private string name;
        private ObservableCollection<Test> tests;
        private string description;

        public Evaluation()
        {
            this.Name = "";
            this.Tests = new ObservableCollection<Test>();
        }
        
        public string Name 
        {
            get{return name;}
            set{name = value;} 
        }
        public ObservableCollection<Test> Tests 
        {
            get { return tests;}
            set { this.tests = value;}
        }

        public string Description 
        {
            get { return description; }
            set { description = value;}
        }

        public bool addTest(Test oneTest)
        {
            bool ret = false;
            if (!this.tests.Contains(oneTest))
            {
                this.tests.Add(oneTest);
                ret = true;
            }
            return ret;
        }

        public void removeTest(Test oneTest) 
        {
            this.tests.Remove(oneTest);
        }        

        public string Error
        {
            get
            {
                return null;
            }
        }

        public string this[string name]
        {
            get
            {
                string result = null;
                if (name == "Name")
                {
                    if (this.name == "")
                    {
                        result = "Ingrese el nombre de la Evluación.";
                    }
                }
                return result;
            }
        }

        /*public bool validOidInTests(int oid)
        {
            bool encontre = false;
            for (int i = 0; i < this.Tests.Count; i++)
            {
                if (this.Tests[i].OID == oid)
                {
                    encontre = true;
                    i = this.Tests.Count;
                }
            }
            return encontre;
        }*/

        /*public bool validNameInTests(string nameTest)
        {
            bool encontre = false;
            for (int i = 0; i < this.Tests.Count; i++)
            {
                if (this.Tests[i].Name.Equals(nameTest))
                {
                    encontre = true;
                    i = this.Tests.Count;
                }
            }
            return encontre;
        }*/

        public override bool Equals(object obj)
        {
            return this.Name.Equals(((Evaluation)obj).Name);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
    }
}
